<html>

	<head>
		<title>Sample Application</title>

		<script type="text/javascript">
			
		function deleteProduct(code)
		{
			var xmlHttp = getXmlHttp();
			xmlHttp.open("DELETE", "rest/products/" + code, true);
			xmlHttp.send(null);
		}
			function addUpdateProduct(code, title)
			{
				var xmlHttp = getXmlHttp();
	            xmlHttp.open("PUT", "rest/products/" + code, true);
				xmlHttp.send("<Product code=\"" + code + "\">" + title + "</Product>");
			}
			
			function getXmlHttp()
			{
				var xmlHttp;
				try
				{
					// Firefox, Opera 8.0+, Safari
					xmlHttp=new XMLHttpRequest();
				}
				catch (e)
				{
					// Internet Explorer
					try
					{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e)
					{
						try
						{
							xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						}
						catch (e)
						{
							alert("Your browser does not support AJAX!");
							return false;
						}
					}
				}
				
				return xmlHttp;
			}
		</script>
	</head>
	<body>
	<form action="rest/products" method="post">
		<table border="0">
			<tr><th colspan="2" align="left">Add Product by HTTP POST</th></tr>
			<tr><td>Code</td> <td><input type="text" name="code" /> </td></tr>
			<tr><td>Title </td><td> <input type="text" name="title" /> </td></tr>
			<tr><td>Description </td><td> <input type="text" name="description" /> </td></tr>
			<tr><td>Price </td><td> <input type="text" name="price" /> </td></tr>
			<tr><td>Rank </td><td> <input type="text" name="rank" /> </td></tr>
			<tr><td>Sell amount </td><td> <input type="text" name="amount" /> </td></tr>
			<tr><td>Image URL </td><td> <input type="text" name="imageURL" /> </td></tr>
			
			<tr>
					<td></td>
					<td><input type="submit" value="Add Product" /></td>
		    </tr>
		 </table>
		
	</form>
	
	
	<form name="AddUpdateProduct">
			<table border="0">
				<tr><th colspan="2" align="left">Add or Update Product by HTTP PUT </th></tr>
				<tr>
					<td colspan="2">(If product with given code already exists, it will be updated. Otherwise it will be added.)</td>
				</tr>
				<tr>
					<td width="10%">Code:</td><td width="90%"><input type="text" name="code"></td>
				</tr>
				<tr>
					<td>Product Title:</td><td><input type="text" name="title"></td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input type="button" value="Add/Update" onClick="addUpdateProduct(AddUpdateProduct.code.value, AddUpdateProduct.title.value); return false;">
					</td>
				</tr>
			</table>
		</form>
	<form name="DeleteProduct">
			<table border="0">
				<tr><th colspan="2" align="left">Delete Product by HTTP DELETE</th></tr>
				<tr>
					<td>Code:</td><td><input type="text" name="code"></td>
				</tr>
				<tr>
					<td></td>
					<td>
						<input type="button" value="Delete" onClick="deleteProduct(DeleteProduct.code.value); return false;">
					</td>
				</tr>
			</table>
		</form>
	
	
	
 
</body>
</html>